<?php

function search ($type){
    $find=  mysql_real_escape_string($_GET['text']);
    if ($type=='title')
        return 'Поиск '.$find;
    if ($type=='content'){
        ob_start();
        $qr=mysql_query('select c.*, cc.title as cname from catalog c left join cat cc on cc.id = c.cat where c.title like "%'.$find.'%" or about like "%'.$find.'%"');
        $text = '';
        $text .=$pagin.'<table width="100%" class="cat_table">
                        <tr><th>Наименование</th>                        
                        <th>Группа</th>
                        <th>Цена</th>
                        ';
        $i = 0; // для матраса
	while ($t = mysql_fetch_assoc($qr)) {
            /*---------------------*/
	   $text .= '<TR';
           $i++;
            if ($i%2==0) $text.= ' class="matras"';
            $text .= '><td width="35%"><a href="/catalog/item/'.$t['id'].'/">'.$t['title'].'</a><br />
                        ';
                            
 if ($_SESSION['level'] >= 5){ 
    
            $text.='<a href="/ADM/edit/' . $t['id'] . '/?vid=catalog" style="color: red">Редактировать</a><br />';
            }
          $text .=      ' </td>
                        <td> '.$t['cname'].' </td>
                        <td>'.$t['price'].'</td></tr>
                    ';
	}
        $text.="</table>".$pagin;
        echo $text;
        return ob_get_clean();
    }
}
?>
